﻿using AiShow.Common;
using AiShow.DAL;
using AiShow.IBLL;
using AiShow.IDAL;
using AiShow.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AiShow.BLL
{
    public class UserManager : IUserManager
    {
        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public OperResult<TBUsers> GetUser(int userId)
        {
            IUserService userService = new UserService();
            TBUsers user = userService.FindByUserId(userId);
            return OperResult<TBUsers>.Succeed(user);
        }

        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="user">用户信息</param>
        /// <returns></returns>
        public OperResult<TBUsers> EditWithoutAvatar(TBUsers user)
        {
            IUserService userService = new UserService();
            try
            {
                TBUsers profileEntity = userService.EditWithoutAvatar(user);
                return OperResult<TBUsers>.Succeed(profileEntity);
            }
            catch (Exception ex)
            {
                return OperResult<TBUsers>.Wrong(ex);
            }
        }

        /// <summary>
        /// 编辑头像
        /// </summary>
        /// <param name="user">用户信息</param>
        /// <returns></returns>
        public OperResult<TBUsers> EditAvatar(TBUsers user)
        {
            IUserService userService = new UserService();
            try
            {
                TBUsers profileEntity = userService.EditAvatar(user);
                return OperResult<TBUsers>.Succeed(profileEntity);
            }
            catch (Exception ex)
            {
                return OperResult<TBUsers>.Wrong(ex);
            }
        }
    }
}
